package com.chonor.mall.service;

import com.chonor.mall.dto.LoginParam;
import com.chonor.mall.dto.RegisterParam;
import com.chonor.mall.model.Member;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.transaction.annotation.Transactional;

/**
 * 会员管理Service
 * Created by macro on 2018/8/3.
 */
public interface MemberService {
    /**
     * 根据用户名获取会员
     */
    Member getByUsername(String username);

    /**
     * 根据会员编号获取会员
     */
    Member getById(Long id);

    /**
     * 用户注册
     */
    @Transactional
    int register(RegisterParam registerParam);

    /**
     * 生成验证码
     */
    String generateAuthCode(String telephone);

    /**
     * 修改密码
     */
    @Transactional
    void updatePassword(String telephone, String password, String authCode);

    /**
     * 获取当前登录会员
     */
    Member getCurrentMember();

    /**
     * 根据会员id修改会员积分
     */
    void updateIntegration(Long id, Integer integration);


    /**
     * 获取用户信息
     */
    UserDetails loadUserByUsername(String username);

    /**
     * 登录后获取token
     */
    String login(LoginParam loginParam);

    /**
     * 刷新token
     */
    String refreshToken(String token);
}
